package controller;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JList;

import manager.BookManager;
import manager.UserManager;

import entity.Book;

import view.BookDetailView;
import view.BookListView;
import view.Index;
import view.UserListView;

public class IndexController {

	private BookController bookController = new BookController();
	private UserController userController = new UserController();
	private Index view;
	
	public static void main(String[] args) {
		new IndexController();
	}
	
	public IndexController() {
		view = new Index();
		view.register(mouseListener);
	}
	
	private MouseListener mouseListener = new MouseListener() {

        public void mouseClicked(MouseEvent e) {
        	JButton j = (JButton) e.getSource();
        	if (j.getText().equals("Show all users")) {
        		new UserListView(UserManager.getInstance().findAll(), userController.lsl);
        	} else {
        		new BookListView(BookManager.getInstance().findAll(), bookController.lsl);
        	}
        }

		@Override
		public void mousePressed(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseReleased(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseEntered(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseExited(MouseEvent e) {
			// TODO Auto-generated method stub
			
		}
		
	};
	
}
